﻿--HEADER Delete benchmark series on cascade

 TRUNCATE TABLE [Analytics].[InvestmentBenchmarkSerie]

 GO

 IF NOT EXISTS (SELECT * 
                FROM sys.foreign_keys 
                WHERE object_id = OBJECT_ID(N'[Analytics].[FK_BenchmarkSeries_Investment]') 
                  AND parent_object_id = OBJECT_ID(N'[Analytics].[InvestmentBenchmarkSerie]'))
BEGIN
    ALTER TABLE [Analytics].[InvestmentBenchmarkSerie] WITH CHECK ADD
    CONSTRAINT FK_BenchmarkSeries_Investment FOREIGN KEY (InvestmentId) REFERENCES [Analytics].[Investment] (Id) ON DELETE CASCADE
END